home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / net / netmenu11.lha / Source / NetMenu.e next >
Text File  |  1997-03-16  |  20KB  |  734 lines

  1. /*
  2. **
  3. **  NetMenu v1.1 ®1996 Peter Gordon
  4. **
  5. **  Just an example of how to make a little internet menu... 
  6. **
  7. **  Defaults set up for the following internet s/w:
  8. **
  9. **  TCP/IP Stack: Miami
  10. **  Browser:      IBrowse
  11. **  IRC Client:   AmIRC
  12. **  FTP Client:   Gui-FTP
  13. **
  14. ** Requires:
  15. ** (to run)       · Arexx to be running (Comes with WB)
  16. **                · WB2.0+              (Errr... Comes with yer Amiga :)
  17. ** (to compile)   · EasyGUI 3.3+        (Aminet: dev/e/easygui*.lha)
  18. **                · EAudio              (Aminet: dev/e/eaudio.lha)
  19. **                · Amiga E             (Aminet: dev/e/amigae*.lha)
  20. **
  21. */
  22.  
  23. OPT OSVERSION=37
  24.  
  25. MODULE 'tools/easygui', 'eaudio', 'libraries/gadtools',
  26.        'intuition/intuition', 'commodities', 'libraries/commodities',
  27.        'exec/ports', 'wb', 'workbench/workbench', 'icon'
  28.  
  29. OBJECT prefs
  30.   matchstr[4]:ARRAY OF CHAR,               -> Filetype validation
  31.   playback_online,  -> Playback rates for samples
  32.   playback_offline,
  33.   playback_irc,
  34.   playback_ftp,
  35.   playback_www,
  36.   playback_email,
  37.   load_tcp_stack[256]:ARRAY OF CHAR,       -> String to execute when opening TCP/IP
  38.   tcp_stack_arexx[256]:ARRAY OF CHAR,      -> Arexx prog to execute on open
  39.   shut_tcp_stack_arexx[256]:ARRAY OF CHAR, -> Arexx prog to execute on close
  40.   load_browser[256]:ARRAY OF CHAR,         -> Etc. etc.
  41.   browser_arexx[256]:ARRAY OF CHAR,
  42.   shut_browser_arexx[256]:ARRAY OF CHAR,
  43.   load_irc[256]:ARRAY OF CHAR,
  44.   irc_arexx[256]:ARRAY OF CHAR,
  45.   shut_irc_arexx[256]:ARRAY OF CHAR,
  46.   load_ftp[256]:ARRAY OF CHAR,
  47.   ftp_arexx[256]:ARRAY OF CHAR,
  48.   shut_ftp_arexx[256]:ARRAY OF CHAR,
  49.   load_email[256]:ARRAY OF CHAR,
  50.   email_arexx[256]:ARRAY OF CHAR,
  51.   shut_email_arexx[256]:ARRAY OF CHAR,
  52.   online_arexx[256]:ARRAY OF CHAR,
  53.   offline_arexx[256]:ARRAY OF CHAR
  54.   x,y:INT
  55. ENDOBJECT
  56.  
  57. DEF onlrx[256]:STRING,   -> E-String for online rexx script name
  58.     oflrx[256]:STRING,   -> E-String for offline rexx script name
  59.     loadtcp[256]:STRING, -> E-String for load TCP string
  60.     tcprx[256]:STRING,   -> E-String for TCP rexx script name
  61.     qtcprx[256]:STRING,  -> E-String for quit TCP rexx script name
  62.     loadwww[256]:STRING,
  63.     wwwrx[256]:STRING,
  64.     qwwwrx[256]:STRING,
  65.     loadirc[256]:STRING,
  66.     ircrx[256]:STRING,
  67.     qircrx[256]:STRING,
  68.     loadftp[256]:STRING,
  69.     ftprx[256]:STRING,
  70.     qftprx[256]:STRING,
  71.     loademail[256]:STRING,
  72.     emailrx[256]:STRING,
  73.     qemailrx[256]:STRING
  74.  
  75. DEF s_online, s_online_len,     -> Online sample and length
  76.     s_offline, s_offline_len,
  77.     s_irc, s_irc_len,
  78.     s_ftp, s_ftp_len,
  79.     s_www, s_www_len,
  80.     s_email, s_email_len,
  81.     our_prefs:prefs,            -> The prefs
  82.     lock,
  83.     gh:PTR TO guihandle,        -> EasyGUI handle
  84.     cx_broker=NIL,              -> Our commodities broker
  85.     cx_broker_mp=NIL:PTR TO mp, -> Broker message port
  86.     dobj:PTR TO diskobject,     -> For our AppIcon
  87.     iconport:PTR TO mp,
  88.     appicon, appmsg:PTR TO appmessage
  89.     
  90. PROC main() HANDLE
  91.   DEF x,y,msg,msgid,msgtype,gmsg
  92.  
  93.   -> Load the prefs
  94.   getPrefs()
  95.  
  96.   -> Get any libs/resources/anything we need
  97.   getStuff()
  98.   
  99.   -> Check if we're run from WB, and if so, lock PROGDIR: and current dir
  100.   -> it...
  101.   IF(wbmessage)
  102.     IF(lock:=Lock('PROGDIR:',-2)) ->ACCESS_READ
  103.       CurrentDir(lock)
  104.     ENDIF
  105.   ENDIF
  106.   
  107.   -> Load the samples
  108.   s_online, s_online_len:=loadRaw('sounds/online.raw')
  109.   s_offline, s_offline_len:=loadRaw('sounds/offline.raw')
  110.   s_ftp, s_ftp_len:=loadRaw('sounds/ftp.raw')
  111.   s_irc, s_irc_len:=loadRaw('sounds/irc.raw')
  112.   s_www, s_www_len:=loadRaw('sounds/www.raw')
  113.   s_email, s_email_len:=loadRaw('sounds/email.raw')
  114.   
  115.   -> Open a please wait window
  116.   gh:=guiinit('!Wait!',
  117.     [BEVEL,
  118.       [TEXT,'Setting up some stuff...',NIL,FALSE,40]
  119.     ])
  120.   
  121.   -> Open TCP/IP stack
  122.   run(our_prefs.load_tcp_stack)
  123.   Delay(50)
  124.   
  125.   -> Run startup arexx script
  126.   rexxecute(our_prefs.tcp_stack_arexx)
  127.   
  128.   -> Get rid of the wait window
  129.   cleangui(gh)
  130.   
  131.   x:=our_prefs.x
  132.   y:=our_prefs.y
  133.   
  134.   -> Open the main window
  135.   gh:=guiinit('NetMenu v1.1',
  136.     [BEVEL,
  137.       [EQROWS,
  138.         [COLS,
  139.           [BUTTON,{online},'Online'],
  140.           [SPACEH],
  141.           [BUTTON,{offline},'Offline'],
  142.           [SPACEH],
  143.           [BUTTON,{www},'WWW'],
  144.           [SPACEH],
  145.           [BUTTON,{irc},'IRC'],
  146.           [SPACEH],
  147.           [BUTTON,{ftp},'FTP'],
  148.           [SPACEH],
  149.           [BUTTON,{email},'E Mail']
  150.         ],
  151.         [BAR],
  152.         [BUTTON,0,'Quit']
  153.       ]
  154.     ],0,0,0,
  155.     [NM_TITLE,0,'Project',0,0,0,0,
  156.      NM_ITEM,0,'Prefs','P',0,0,{prefs},
  157.      NM_ITEM,0,'Iconify','I',0,0,1,
  158.      NM_ITEM,0,'Quit','Q',0,0,0,
  159.      0,0,0,0,0,0,0]:newmenu,
  160.      0,x,y)
  161.   
  162.   -> Wait till the window is closed
  163.   REPEAT
  164.     WaitTOF() -> Don't hog the system
  165.     IF(msg:=GetMsg(cx_broker_mp))
  166.       msgid:=CxMsgID(msg)
  167.       msgtype:=CxMsgType(msg)
  168.       ReplyMsg(msg)
  169.       IF(msgtype=CXM_COMMAND)
  170.         SELECT msgid
  171.         CASE CXCMD_DISABLE
  172.           ActivateCxObj(cx_broker, FALSE)
  173.         CASE CXCMD_ENABLE
  174.           ActivateCxObj(cx_broker, TRUE)
  175.         CASE CXCMD_DISAPPEAR
  176.           iconify()
  177.         CASE CXCMD_APPEAR
  178.           uniconify()
  179.         ENDSELECT
  180.       ENDIF
  181.     ENDIF
  182.     IF(gh) THEN gmsg:=guimessage(gh)
  183.     IF(gmsg=1)
  184.       iconify()
  185.     ENDIF
  186.     IF(dobj)
  187.       IF(appmsg:=GetMsg(iconport))
  188.         ReplyMsg(appmsg)
  189.         uniconify()
  190.       ENDIF
  191.     ENDIF
  192.   UNTIL (gmsg=0) OR (msgid=CXCMD_KILL) OR (msgid=CXCMD_UNIQUE)
  193.  
  194.   -> Make sure we're uniconified
  195.   uniconify()
  196.  
  197.   -> Close the window
  198.   cleangui(gh)
  199.   
  200.   -> If browser is running, close it
  201.   rexxecute(our_prefs.shut_browser_arexx)
  202.   
  203.   -> If FTP is running, close it
  204.   rexxecute(our_prefs.shut_ftp_arexx)
  205.   
  206.   -> If IRC is running, close it
  207.   rexxecute(our_prefs.shut_ftp_arexx)
  208.   
  209.   -> Quit TCP/IP stack
  210.   rexxecute(our_prefs.shut_tcp_stack_arexx)
  211.   stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  212.   
  213.   -> Free up everything
  214.   freeStuff()
  215.   
  216.   -> Unlock PROGDIR:
  217.   IF(lock)
  218.     UnLock(lock)
  219.   ENDIF
  220. EXCEPT
  221.   stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  222.   WriteF('Fatal Error!\n')
  223. ENDPROC
  224.  
  225. PROC online()
  226.   -> Go online
  227.   rexxecute(our_prefs.online_arexx)
  228.   IF(s_online)
  229.     playData(s_online,s_online_len,our_prefs.playback_online,CHAN_LEFT1+CHAN_RIGHT1,64)
  230.     WaitTOF()
  231.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  232.   ENDIF
  233. ENDPROC  
  234.  
  235. PROC offline()
  236.   -> Go offline
  237.   rexxecute(our_prefs.offline_arexx)
  238.   IF(s_offline)
  239.     playData(s_offline,s_offline_len,our_prefs.playback_offline,CHAN_LEFT1+CHAN_RIGHT1,64)
  240.     WaitTOF()
  241.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  242.   ENDIF
  243. ENDPROC  
  244.  
  245. PROC www()
  246.   -> Run IBrowse
  247.   run(our_prefs.load_browser)
  248.   IF(StrLen(our_prefs.browser_arexx)>0)
  249.     Delay(100) -> Wait 2 secs
  250.     rexxecute(our_prefs.browser_arexx)
  251.   ENDIF
  252.   IF(s_www)
  253.     playData(s_www,s_www_len,our_prefs.playback_www,CHAN_LEFT1+CHAN_RIGHT1,64)
  254.     WaitTOF()
  255.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  256.   ENDIF
  257. ENDPROC
  258.  
  259. PROC irc()
  260.   -> Run AmIRC
  261.   run(our_prefs.load_irc)
  262.   IF(StrLen(our_prefs.irc_arexx)>0)
  263.     Delay(100) -> Wait 2 secs
  264.     rexxecute(our_prefs.irc_arexx)
  265.   ENDIF
  266.   IF(s_irc)
  267.     playData(s_irc,s_irc_len,our_prefs.playback_irc,CHAN_LEFT1+CHAN_RIGHT1,64)
  268.     WaitTOF()
  269.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  270.   ENDIF
  271. ENDPROC
  272.  
  273. PROC ftp()
  274.   -> Run GUI-FTP
  275.   run(our_prefs.load_ftp)
  276.   IF(StrLen(our_prefs.ftp_arexx)>0)
  277.     Delay(100) -> Wait 2 secs
  278.     rexxecute(our_prefs.ftp_arexx)
  279.   ENDIF
  280.   IF(s_ftp)
  281.     playData(s_ftp,s_ftp_len,our_prefs.playback_ftp,CHAN_LEFT1+CHAN_RIGHT1,64)
  282.     WaitTOF()
  283.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  284.   ENDIF
  285. ENDPROC
  286.  
  287. PROC email()
  288.   -> Run E-Mail
  289.   run(our_prefs.load_email)
  290.   IF(StrLen(our_prefs.email_arexx)>0)
  291.     Delay(100) -> Wait 2 secs
  292.     rexxecute(our_prefs.email_arexx)
  293.   ENDIF
  294.   IF(s_email)
  295.     playData(s_email,s_email_len,our_prefs.playback_email,CHAN_LEFT1+CHAN_RIGHT1,64)
  296.     WaitTOF()
  297.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  298.   ENDIF
  299. ENDPROC
  300.  
  301. -> Run an arexx script
  302. PROC rexxecute(str)
  303.   DEF mstr[256]:STRING,h
  304.   IF(lock)
  305.     CurrentDir(lock)
  306.   ENDIF
  307.   IF(h:=Open('NIL:',NEWFILE))
  308.     -> Normally I wouldn't specify "sys:rexxc/" but i cant get it to
  309.     -> work from the workbench icon without it (?)
  310.     StringF(mstr,'sys:rexxc/rx >NIL: \s',str)
  311.     Execute(mstr,0,h)
  312.     Close(h)
  313.   ENDIF
  314. ENDPROC  
  315.  
  316. -> Run a program
  317. PROC run(name)
  318.   StringF(onlrx,'Run >NIL: \s',name)
  319.   Execute(onlrx,0,0)
  320. ENDPROC
  321.  
  322. PROC getPrefs()
  323.   DEF h, gp, size
  324.   gp:=0
  325.   
  326.   our_prefs.x:=-1
  327.   our_prefs.y:=-1
  328.  
  329.   -> Check the file length
  330.   size:=FileLength('s:NetMenu.prefs')
  331.   IF(size=SIZEOF prefs) OR (size=SIZEOF prefs-4)
  332.     IF(h:=Open('s:NetMenu.prefs',OLDFILE))
  333.       Read(h,our_prefs,size)
  334.       Close(h)
  335.       IF(StrCmp(our_prefs.matchstr,'NMP',4)) THEN gp:=1
  336.     ENDIF
  337.   ENDIF
  338.   
  339.   -> If we couldn't load the prefs properly, make a new prefs file
  340.   -> With all the defaults
  341.   IF(gp=0)
  342.     doCopy(our_prefs.matchstr,'NMP')
  343.     our_prefs.playback_online:=13964
  344.     our_prefs.playback_offline:=13964
  345.     our_prefs.playback_www:=8404
  346.     our_prefs.playback_irc:=8404
  347.     our_prefs.playback_ftp:=16384
  348.     our_prefs.playback_email:=8404
  349.     doCopy(our_prefs.load_tcp_stack,'Miami')
  350.     doCopy(our_prefs.tcp_stack_arexx,'rexx/hide_miami.rexx')
  351.     doCopy(our_prefs.shut_tcp_stack_arexx,'rexx/quit_miami.rexx')
  352.     doCopy(our_prefs.load_browser,'IBrowse')
  353.     doCopy(our_prefs.browser_arexx,'')
  354.     doCopy(our_prefs.shut_browser_arexx,'rexx/quit_browser.rexx')
  355.     doCopy(our_prefs.load_irc,'AmIRC')
  356.     doCopy(our_prefs.irc_arexx,'')
  357.     doCopy(our_prefs.shut_irc_arexx,'rexx/Close_irc.rexx')
  358.     doCopy(our_prefs.load_ftp,'GUI-FTP')
  359.     doCopy(our_prefs.ftp_arexx,'')
  360.     doCopy(our_prefs.shut_ftp_arexx,'rexx/Close_ftp.rexx')
  361.     doCopy(our_prefs.online_arexx,'rexx/Online.rexx')
  362.     doCopy(our_prefs.offline_arexx,'rexx/Offline.rexx')
  363.     savePrefs()
  364.   ENDIF
  365. ENDPROC
  366.     
  367. PROC savePrefs()
  368.   DEF h
  369.   IF(h:=Open('s:NetMenu.prefs',NEWFILE))
  370.     our_prefs.x:=gh.wnd.leftedge
  371.     our_prefs.y:=gh.wnd.topedge
  372.     Write(h,our_prefs,SIZEOF prefs)
  373.     Close(h)
  374.   ENDIF
  375. ENDPROC
  376.  
  377. PROC doCopy(da,s)
  378.   DEF cnt
  379.   FOR cnt:=0 TO StrLen(s)
  380.     PutChar(da+cnt,Char(s+cnt))
  381.   ENDFOR
  382. ENDPROC
  383.  
  384. PROC prefs()
  385.   -> Copy all strings to E-Strings for EasyGUI
  386.   StrCopy(onlrx,our_prefs.online_arexx)
  387.   StrCopy(oflrx,our_prefs.offline_arexx)
  388.   StrCopy(loadtcp,our_prefs.load_tcp_stack)
  389.   StrCopy(tcprx,our_prefs.tcp_stack_arexx)
  390.   StrCopy(qtcprx,our_prefs.shut_tcp_stack_arexx)
  391.   StrCopy(loadwww,our_prefs.load_browser)
  392.   StrCopy(wwwrx,our_prefs.browser_arexx)
  393.   StrCopy(qwwwrx,our_prefs.shut_browser_arexx)
  394.   StrCopy(loadirc,our_prefs.load_irc)
  395.   StrCopy(ircrx,our_prefs.irc_arexx)
  396.   StrCopy(qircrx,our_prefs.shut_irc_arexx)
  397.   StrCopy(loadftp,our_prefs.load_ftp)
  398.   StrCopy(ftprx,our_prefs.ftp_arexx)
  399.   StrCopy(qftprx,our_prefs.shut_ftp_arexx)
  400.   StrCopy(loademail,our_prefs.load_email)
  401.   StrCopy(emailrx,our_prefs.email_arexx)
  402.   StrCopy(qemailrx,our_prefs.shut_email_arexx)
  403.   
  404.   -> Opent the prefs window
  405.   easygui('NetMenu Prefs',
  406.     [BEVEL,
  407.       [EQROWS,
  408.         [BUTTON,{prf_tcp},'TCP prefs'],
  409.         [BUTTON,{prf_www},'WWW prefs'],
  410.         [BUTTON,{prf_irc},'IRC prefs'],
  411.         [BUTTON,{prf_ftp},'FTP prefs'],
  412.         [BUTTON,{prf_email},'Email Prefs'],
  413.         [BUTTON,{prf_dia},'Dial prefs'],
  414.         [BUTTON,{prf_sound},'Sound prefs'],
  415.         [BAR],
  416.         [COLS,
  417.           [BUTTON,0,'Close'],
  418.           [SPACEH],
  419.           [BUTTON,{savePrefs},'Save Prefs']
  420.         ]
  421.       ]
  422.     ])
  423. ENDPROC
  424.  
  425. PROC prf_tcp()
  426.   easygui('NetMenu Prefs -TCP',
  427.     [BEVEL,
  428.       [EQROWS,
  429.         [STR,{dummy},'_Load TCP:',loadtcp,255,20,0,0,Char('l')],
  430.         [STR,{dummy},'_TCP Arexx:',tcprx,255,20,0,0,Char('t')],
  431.         [STR,{dummy},'_Shut TCP:',qtcprx,255,20,0,0,Char('s')],
  432.         [BAR],
  433.         [BUTTON,0,'Close']
  434.       ]
  435.     ])
  436.     
  437.   -> Put the changed strings back into the prefs structure
  438.   doCopy(our_prefs.load_tcp_stack,loadtcp)
  439.   doCopy(our_prefs.tcp_stack_arexx,tcprx)
  440.   doCopy(our_prefs.shut_tcp_stack_arexx,qtcprx)
  441. ENDPROC
  442.  
  443. PROC prf_email()
  444.   easygui('NetMenu Prefs -EMail',
  445.     [BEVEL,
  446.       [EQROWS,
  447.         [STR,{dummy},'_Load EMail:',loademail,255,20,0,0,Char('l')],
  448.         [STR,{dummy},'_EMail Arexx:',emailrx,255,20,0,0,Char('e')],
  449.         [STR,{dummy},'_Shut EMail:',qemailrx,255,20,0,0,Char('s')],
  450.         [BAR],
  451.         [BUTTON,0,'Close']
  452.       ]
  453.     ])
  454.     
  455.   -> Put the changed strings back into the prefs structure
  456.   doCopy(our_prefs.load_email,loademail)
  457.   doCopy(our_prefs.email_arexx,emailrx)
  458.   doCopy(our_prefs.shut_email_arexx,qemailrx)
  459. ENDPROC
  460.  
  461. PROC prf_www()
  462.   easygui('NetMenu Prefs -WWW',
  463.     [BEVEL,
  464.       [EQROWS,
  465.         [STR,{dummy},'_Load WWW:',loadwww,255,20,0,0,Char('l')],
  466.         [STR,{dummy},'_WWW Arexx:',wwwrx,255,20,0,0,Char('w')],
  467.         [STR,{dummy},'_Shut WWW:',qwwwrx,255,20,0,0,Char('s')],
  468.         [BAR],
  469.         [BUTTON,0,'Close']
  470.       ]
  471.     ])
  472.   doCopy(our_prefs.load_browser,loadwww)
  473.   doCopy(our_prefs.browser_arexx,wwwrx)
  474.   doCopy(our_prefs.shut_browser_arexx,qwwwrx)
  475. ENDPROC
  476.  
  477. PROC prf_irc()
  478.   easygui('NetMenu Prefs -IRC',
  479.     [BEVEL,
  480.       [EQROWS,
  481.         [STR,{dummy},'_Load IRC:',loadirc,255,20,0,0,Char('l')],
  482.         [STR,{dummy},'_IRC Arexx:',ircrx,255,20,0,0,Char('i')],
  483.         [STR,{dummy},'_Shut IRC:',qircrx,255,20,0,0,Char('s')],
  484.         [BAR],
  485.         [BUTTON,0,'Close']
  486.       ]
  487.     ])
  488.   doCopy(our_prefs.load_irc,loadirc)
  489.   doCopy(our_prefs.irc_arexx,ircrx)
  490.   doCopy(our_prefs.shut_irc_arexx,qircrx)
  491. ENDPROC
  492.  
  493. PROC prf_ftp()
  494.   easygui('NetMenu Prefs -FTP',
  495.     [BEVEL,
  496.       [EQROWS,
  497.         [STR,{dummy},'_Load FTP:',loadftp,255,20,0,0,Char('l')],
  498.         [STR,{dummy},'_FTP Arexx:',ftprx,255,20,0,0,Char('f')],
  499.         [STR,{dummy},'_Shut FTP:',qftprx,255,20,0,0,Char('s')],
  500.         [BAR],
  501.         [BUTTON,0,'Close']
  502.       ]
  503.     ])
  504.   doCopy(our_prefs.load_ftp,loadftp)
  505.   doCopy(our_prefs.ftp_arexx,ftprx)
  506.   doCopy(our_prefs.shut_ftp_arexx,qftprx)
  507. ENDPROC
  508.  
  509. PROC prf_dia()
  510.   easygui('NetMenu Prefs -Dial',
  511.     [BEVEL,
  512.       [EQROWS,
  513.         [STR,{dummy},'_Online Arexx:',onlrx,255,20,0,0,Char('o')],
  514.         [STR,{dummy},'O_ffline Arexx:',oflrx,255,20,0,0,Char('f')],
  515.         [BAR],
  516.         [BUTTON,0,'Close']
  517.       ]
  518.     ])
  519.   doCopy(our_prefs.online_arexx,onlrx)
  520.   doCopy(our_prefs.offline_arexx,oflrx)
  521. ENDPROC
  522.  
  523. PROC prf_sound()
  524.   easygui('NetMenu Prefs -Sound',
  525.     [BEVEL,
  526.       [EQROWS,
  527.         [COLS,
  528.           [SLIDE,{sound1},'Online.RAW playrate:        ',0,8404,32767,our_prefs.playback_online,30,'%6ld',0,0,(s_online=0)],
  529.           [BUTTON,{stest1},'Test',0,0,0,(s_online=0)]
  530.         ],
  531.         [COLS,
  532.           [SLIDE,{sound2},'Offline.RAW playrate:       ',0,8404,32767,our_prefs.playback_offline,30,'%6ld',0,0,(s_offline=0)],
  533.           [BUTTON,{stest2},'Test',0,0,0,(s_offline=0)]
  534.         ],
  535.         [COLS,
  536.           [SLIDE,{sound3},'WWW.RAW playrate:           ',0,8404,32767,our_prefs.playback_www,30,'%6ld',0,0,(s_www=0)],
  537.           [BUTTON,{stest3},'Test',0,0,0,(s_www=0)]
  538.         ],
  539.         [COLS,
  540.           [SLIDE,{sound4},'IRC.RAW playrate:           ',0,8404,32767,our_prefs.playback_irc,30,'%6ld',0,0,(s_irc=0)],
  541.           [BUTTON,{stest4},'Test',0,0,0,(s_irc=0)]
  542.         ],
  543.         [COLS,
  544.           [SLIDE,{sound5},'FTP.RAW playrate:           ',0,8404,32767,our_prefs.playback_ftp,30,'%6ld',0,0,(s_ftp=0)],
  545.           [BUTTON,{stest5},'Test',0,0,0,(s_ftp=0)]
  546.         ],
  547.         [COLS,
  548.           [SLIDE,{sound6},'EMAIL.RAW playrate:         ',0,8404,32767,our_prefs.playback_email,30,'%6ld',0,0,(s_email=0)],
  549.           [BUTTON,{stest6},'Test',0,0,0,(s_email=0)]
  550.         ],
  551.         [BAR],
  552.         [BUTTON,0,'Close']
  553.       ]
  554.     ])
  555. ENDPROC
  556.  
  557. PROC sound1(null,val)
  558.   our_prefs.playback_online:=val
  559. ENDPROC
  560. PROC stest1()
  561.   IF(s_online)
  562.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  563.     WaitTOF()
  564.     playData(s_online,s_online_len,our_prefs.playback_online,CHAN_LEFT1+CHAN_RIGHT1,64)
  565.     WaitTOF()
  566.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  567.   ENDIF
  568. ENDPROC  
  569.  
  570. PROC sound2(null,val)
  571.   our_prefs.playback_offline:=val
  572. ENDPROC
  573. PROC stest2()
  574.   IF(s_offline)
  575.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  576.     WaitTOF()
  577.     playData(s_offline,s_offline_len,our_prefs.playback_offline,CHAN_LEFT1+CHAN_RIGHT1,64)
  578.     WaitTOF()
  579.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  580.   ENDIF
  581. ENDPROC  
  582.  
  583. PROC sound3(null,val)
  584.   our_prefs.playback_www:=val
  585. ENDPROC
  586. PROC stest3()
  587.   IF(s_online)
  588.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  589.     WaitTOF()
  590.     playData(s_www,s_www_len,our_prefs.playback_www,CHAN_LEFT1+CHAN_RIGHT1,64)
  591.     WaitTOF()
  592.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  593.   ENDIF
  594. ENDPROC  
  595.  
  596. PROC sound4(null,val)
  597.   our_prefs.playback_irc:=val
  598. ENDPROC
  599. PROC stest4()
  600.   IF(s_irc)
  601.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  602.     WaitTOF()
  603.     playData(s_irc,s_irc_len,our_prefs.playback_irc,CHAN_LEFT1+CHAN_RIGHT1,64)
  604.     WaitTOF()
  605.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  606.   ENDIF
  607. ENDPROC  
  608.  
  609. PROC sound5(null,val)
  610.   our_prefs.playback_ftp:=val
  611. ENDPROC
  612. PROC stest5()
  613.   IF(s_ftp)
  614.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  615.     WaitTOF()
  616.     playData(s_ftp,s_ftp_len,our_prefs.playback_ftp,CHAN_LEFT1+CHAN_RIGHT1,64)
  617.     WaitTOF()
  618.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  619.   ENDIF
  620. ENDPROC  
  621.  
  622. PROC sound6(null,val)
  623.   our_prefs.playback_email:=val
  624. ENDPROC
  625. PROC stest6()
  626.   IF(s_email)
  627.     stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
  628.     WaitTOF()
  629.     playData(s_email,s_email_len,our_prefs.playback_email,CHAN_LEFT1+CHAN_RIGHT1,64)
  630.     WaitTOF()
  631.     exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
  632.   ENDIF
  633. ENDPROC  
  634.  
  635. -> Used when you dont want an action for a button, but you also dont
  636. -> want that button to close the gui
  637. PROC dummy()
  638. ENDPROC
  639.  
  640. -> Anything we need to open
  641. PROC getStuff()
  642.   cxbase:=OpenLibrary('commodities.library',37)
  643.   iconbase:=OpenLibrary('icon.library',37)
  644.   workbenchbase:=OpenLibrary('workbench.library',37)
  645.   
  646.   -> Setup all the commodities crap
  647.   IF(cxbase)
  648.     IF(cx_broker_mp:=CreateMsgPort())
  649.       cx_broker:=CxBroker([NB_VERSION, 0,
  650.                            'NetMenu',
  651.                            'NetMenu v1.1',
  652.                            'Internet App Launcher by P. Gordon',
  653.                            NBU_UNIQUE OR NBU_NOTIFY,
  654.                            TRUE,0,0,cx_broker_mp,0]:newbroker,NIL)
  655.       ActivateCxObj(cx_broker,TRUE)
  656.     ENDIF
  657.   ENDIF
  658. ENDPROC
  659.  
  660. PROC freeStuff()
  661.   DEF msg
  662.   IF(cx_broker) THEN DeleteCxObjAll(cx_broker)
  663.   IF(cx_broker_mp)
  664.     WHILE msg:=GetMsg(cx_broker_mp) DO ReplyMsg(msg)
  665.     DeleteMsgPort(cx_broker_mp)
  666.   ENDIF
  667.   IF(cxbase) THEN CloseLibrary(cxbase)
  668.   IF(iconbase) THEN CloseLibrary(iconbase)
  669.   IF(workbenchbase) THEN CloseLibrary(workbenchbase)
  670. ENDPROC
  671.  
  672. PROC iconify()  
  673.   IF(dobj) THEN RETURN -> We are already iconified, so return
  674.   
  675.   -> Initialise our icon
  676.   dobj:=GetDefDiskObject(WBTOOL)
  677.   dobj.type:=NIL
  678.   
  679.   -> Get a message port
  680.   IF(iconport:=CreateMsgPort())
  681.     -> Add the app icon to workbench
  682.     appicon:=AddAppIconA(0,0,'NetMenu',iconport,NIL,dobj,NIL)
  683.   ELSE
  684.     FreeDiskObject(dobj)
  685.     dobj:=0
  686.     RETURN
  687.   ENDIF
  688.  
  689.   -> If the gui is open, close it
  690.   IF(gh) THEN cleangui(gh)
  691.   gh:=0
  692. ENDPROC
  693.  
  694. PROC uniconify()
  695.   IF(dobj=0) THEN RETURN -> We are already uniconified
  696.   -> Remove the icon
  697.   IF(appicon) THEN RemoveAppIcon(appicon)
  698.   -> Remove the port
  699.   IF(iconport)
  700.     -> Clear away any messages that arrived at the last moment
  701.     WHILE appmsg:=GetMsg(iconport) DO ReplyMsg(appmsg)
  702.     DeleteMsgPort(iconport)
  703.   ENDIF
  704.   FreeDiskObject(dobj)
  705.   dobj:=0
  706.   -> Open the main window
  707.   gh:=guiinit('NetMenu v1.1',
  708.     [BEVEL,
  709.       [EQROWS,
  710.         [COLS,
  711.           [BUTTON,{online},'Online'],
  712.           [SPACEH],
  713.           [BUTTON,{offline},'Offline'],
  714.           [SPACEH],
  715.           [BUTTON,{www},'WWW'],
  716.           [SPACEH],
  717.           [BUTTON,{irc},'IRC'],
  718.           [SPACEH],
  719.           [BUTTON,{ftp},'FTP'],
  720.           [SPACEH],
  721.           [BUTTON,{email},'E Mail']
  722.         ],
  723.         [BAR],
  724.         [BUTTON,0,'Quit']
  725.       ]
  726.     ],0,0,0,
  727.     [NM_TITLE,0,'Project',0,0,0,0,
  728.      NM_ITEM,0,'Prefs','P',0,0,{prefs},
  729.      NM_ITEM,0,'Iconify','I',0,0,1,
  730.      NM_ITEM,0,'Quit','Q',0,0,0,
  731.      0,0,0,0,0,0,0]:newmenu,
  732.      0,our_prefs.x,our_prefs.y)
  733. ENDPROC
  734.